Skip to content

Conversation

@FROLOV-KI
Copy link

  1. Добавлен GoalService
  2. Добавлен GoalController
  3. Добавлен GoalMapper
  4. Добавлены кастомные исключения для сущностей goal и skill 5) Добавлен SkillService
  5. Добавлен GoalExceptionHandler

FROLOV-KI added 2 commits May 8, 2025 20:04
1) Добавлен GoalService
2) Добавлен GoalController
3) Добавлен GoalMapper
4) Добавлены кастомные исключения для сущностей goal и skill
5) Добавлен SkillService
6) Добавлен GoalExceptionHandler
1) Вызов маппера перенесен в контроллер
2) Добавлены классы валидаторы
FROLOV-KI added 2 commits May 9, 2025 21:11
1) Удален GoalExceptionHandler.java
2) Добавлен метод удаление связи цель - скилл
private final CreateGoalMapperImpl createGoalMapper;
private final UpdateGoalMapperImpl updateGoalMapper;

@PostMapping("/create")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostMapping самодостаточный для create, его лучше без параметров оставить, и по этой url /api/v1/goal делать create

.body(createGoalMapper.goalToDto(createdGoal));
}

@PutMapping("/update/{goalId}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже /update не нужен в пути

return ResponseEntity.ok(updateGoalMapper.goalToDto(createdGoal));
}

@DeleteMapping("/delete/{goalId}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И /delete не нужен в пути

Copy link

@20cognosce 20cognosce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нормально, но чересчур многовато получилось для этой задачи, 700 строк


@JsonInclude(JsonInclude.Include.NON_NULL)
public record UpdateGoalDto(
@NotBlank(message = "Empty goal title not allowed!") String title,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно не писать подробные сообщения

Comment on lines +47 to +49
@Query(nativeQuery = true, value = """
DELETE FROM goal_skill
WHERE goal_id = :goalId""")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше не нативкой это делать, а через JPA

Comment on lines +52 to +55
@Query(nativeQuery = true, value = """
DELETE FROM user_goal ug
WHERE ug.user_id = :userId AND ug.goal_id = :goalId
""")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Comment on lines +26 to +28
String notExistingSkillsId = absentSkillsId.stream()
.map(String::valueOf)
.collect(Collectors.joining(", "));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это целое действие только ради лога, такое

goalRepository.removeGoalFromUser(userContext.getUserId(), goalId);

if (goalRepository.findUsersByGoalId(goalId).isEmpty()) {
goalRepository.findByParent(goalId).forEach(goalRepository::delete);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что со вложенностью-то решили? может сделаешь тогда ограничение, что если у цели есть родитель, то она сама не может быть родителем? чтобы был 1 уровень вложенности

@20cognosce 20cognosce merged commit e426885 into hippogriff-master-stream10 May 22, 2025
@20cognosce 20cognosce deleted the feature/BJS2-77992-add-goal branch May 22, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants